package com.garen.sys.dao.impl;

import com.garen.sys.dao.IFireApkDao;
import com.garen.sys.entity.FireApk;
import com.garen.utils.MapBuilder;
import com.garen.common.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;


@Repository
public class FireApkDaoImpl extends BaseDao<FireApk> implements IFireApkDao {

	@PostConstruct
	private void init(){
		initOrm(FireApk.class);
	}

	/*
	 * 获取指定类型最新版本apk
	 * */
	public FireApk getLastApk(FireApk fireApk) {
		String sql = "select * from fire_apk where apk_type =:apkType order by apk_version desc ";
		Map<String,Object> paramMap = new MapBuilder()
				.put("apkType", fireApk.getApkType())
				.build();
		List<FireApk> apkList = getListBySQL(sql, paramMap);
		log.debug(apkList);
		return apkList.isEmpty()?null:apkList.get(0);
	}
	
}
